<div class="social">
  <hr/>
  <h2>立刻分享</h2>

  <div class="share">
    {% assign share-url = page.url | prepend: site.baseurl | prepend: site.url %}

    <a
      href="https://twitter.com/intent/tweet?text={{ page.title }}&url={{ share-url }}&via={{ site.twitter }}&original_referer={{ share-url }}"
      rel="noreferrer nofollow noopener"
      target="_blank"
      title="Twitter"
      onclick="plausible('Twitter 分享')"
    >
      <img src="{{ '/images/twitter.svg' | prepend: site.baseurl }}" alt="Twitter" />
    </a>
    
    <a
      href="https://telegram.me/share/url?text={{ page.title }}&url={{ share-url }}"
      rel="noreferrer nofollow noopener"
      target="_blank"
      title="Telegram"
      onclick="plausible('Telegram 分享')"
    >
      <img src="{{ '/images/telegram.svg' | prepend: site.baseurl }}" alt="Telegram" />
    </a>

    <a
      href="https://service.weibo.com/share/share.php?title={{ page.title }}&url={{ share-url }}"
      rel="noreferrer nofollow noopener"
      target="_blank"
      title="微博"
      onclick="plausible('微博分享')"
    >
      <img src="{{ '/images/weibo.png' | prepend: site.baseurl }}" alt="微博" />
    </a>

    <!-- <a
    href="https://connect.qq.com/widget/shareqq/index.html?url={{ share-url }}&title={{ page.title }}&desc={{ page.description }}&pics={{ page.image }}"
    rel="noreferrer nofollow noopener"
    target="_blank"
    title="QQ"
    onclick="plausible('QQ 分享')"
  >
    <img src="{{ '/images/qq.svg' | prepend: site.baseurl }}" alt="QQ" />
    </a> -->

    <a
      href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{ share-url }}&title={{ page.title }}&desc={{ page.description }}&pics={{ page.image }}"
      rel="noreferrer nofollow noopener"
      target="_blank"
      title="QQ 空间"
      onclick="plausible('QQ 空间分享')"
    >
      <img src="{{ '/images/qzone.png' | prepend: site.baseurl }}" alt="QQ 空间" />
    </a>

    <a
      href="{{ page.url | prepend: site.baseurl | prepend: site.url }}"
      title="链接"
      onclick="return share()"
    >
      <img src="{{ '/images/edit-copy-32.svg' | prepend: site.baseurl }}" alt="链接" />
    </a>

    
  </div>
</div>

<script>
function share() {
  plausible('链接分享');

  if (navigator.share) {
    navigator.share({
      title: "{{ page.title }}",
      text: "{{ page.description }}",
      url: "{{ page.url | prepend: site.baseurl | prepend: site.url }}",
    })
    .catch((error) => console.log("Error sharing / 分享失败", error));

    return false;
  } else {
    console.log("Sharing not supported; falling back to link / 不支持分享，已回滚为链接");
    return true;
  }
}
</script>
